package com.partsoft.spring.webapp;

import java.util.Locale;

import org.springframework.util.StringUtils;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

public class JspResourceViewResolver extends InternalResourceViewResolver {
	
	private String viewNamePrefix = "/jsp/";
	
	public String getViewNamePrefix() {
		return viewNamePrefix;
	}

	public void setViewNamePrefix(String viewNamePrefix) {
		this.viewNamePrefix = viewNamePrefix;
	}

	@Override
	protected boolean canHandle(String viewName, Locale locale) {
		boolean result = super.canHandle(viewName, locale);
		if (result && StringUtils.hasText(getViewNamePrefix())) {
			result = viewName.startsWith(getViewNamePrefix());
		}
		return result;
	}
		
}
